package br.edu.infnet.avaliacao.sessao;

import java.io.Serializable;

import javax.servlet.http.HttpServletRequest;

import br.com.caelum.vraptor.ioc.Component;
import br.com.caelum.vraptor.ioc.SessionScoped;
import br.edu.infnet.avaliacao.model.Aluno;

@Component
@SessionScoped
public class AlunoWeb implements Serializable {

	private static final long serialVersionUID = 1L;
	private Aluno aluno;
	private HttpServletRequest request;
	
	public AlunoWeb(HttpServletRequest request) {
		this.request = request;
	}
	
	public void login(Aluno aluno){
		this.aluno = aluno;
	}
	
	
	public boolean isLogado(){
		return this.aluno != null;
	}
	
	public void logout(){
		this.aluno = null;
		request.getSession().invalidate();
	}
	
	public Aluno getAluno(){
		return this.aluno;
	}
}
